import request from "@/utils/request.js";

export const listUser = async () => {
    const res = await request.get('/user/list');
    return res.map(e => ({...e, value: e.id, label: e.nickname}))
}

export const isDefaultOptions = [
    {value: 0, label: '否', type: 'primary'},
    {value: 1, label: '是', type: 'info'},
]

export const fields = [
    {
        prop: 'userId',
        label: '所属用户',
        type: 'remote-select',
        api: listUser,
        width: 120,
    },
    {
        prop: 'recipient',
        label: '收件人',
        type: 'text',
        width: 170,
    },
    {
        prop: 'phone',
        label: '手机号',
        type: 'text',
        search: true,
        width: 170,
    },
    {
        prop: 'address',
        label: '详细地址',
        type: 'text',
        search: true,
        width: 170,
    },
    {
        prop: 'isDefault',
        label: '是否默认',
        type: 'switch',
        options: isDefaultOptions,
        search: true,
        width: 170,
    },
    {
        prop: 'createTime',
        label: '创建时间',
        type: 'datetime',
        formHidden: true,
        width: 190,
    }
]